In [3]:
from miscpy.utils.sympyhelpers import *
init_printing()
In [4]:
M,h,m1,m2,th1,th2,b,l1,l2 = \
symbols('M,h,m_1,m_2,theta_1,theta_2,beta,l_1,l_2')
In [5]:
I_O_cab = M*2/3*h**2/4*eye(3); I_O_cab
Out[5]:
In [6]:
I_G1_m1_B = m1*l1**2/12*(eye(3) - diag(1,0,0)); I_G1_m1_B
Out[6]:
In [7]:
aCb = Matrix(([cos(th1),-sin(th1),0],[sin(th1),cos(th1),0],[0,0,1])); aCb
Out[7]:
In [8]:
I_G1_m1_A = aCb*I_G1_m1_B*aCb.transpose(); I_G1_m1_A
Out[8]:
In [9]:
r_O_G1 = aCb*Matrix([-l1/2,0,0]) + Matrix([-h/2,0,0]); r_O_G1
Out[9]:
In [10]:
I_O_m1_A = simplify(I_G1_m1_A + m1*((r_O_G1.transpose()*r_O_G1)[0]*eye(3) - r_O_G1*r_O_G1.transpose())); I_O_m1_A
Out[10]:
In [11]:
I_G2_m2_C = m2*l2**2/12*(eye(3) - diag(1,0,0)); I_G2_m2_C
Out[11]:
In [12]:
bCc = Matrix(([cos(b),sin(b),0],[-sin(b),cos(b),0],[0,0,1])); bCc
Out[12]:
In [13]:
aCc = simplify(aCb*bCc); aCc
Out[13]:
In [14]:
aCc = aCc.subs(b-th1,th2); aCc
Out[14]:
In [15]:
I_G2_m2_A = aCc*I_G2_m2_C*aCc.transpose(); I_G2_m2_A
Out[15]:
In [16]:
r_O_G2 = aCc*Matrix([-l2/2,0,0]) + aCb*Matrix([-l1,0,0]) + Matrix([-h/2,0,0]); r_O_G2
Out[16]:
In [17]:
I_O_m2_A = simplify(I_G2_m2_A + m2*((r_O_G2.transpose()*r_O_G2)[0]*eye(3) - r_O_G2*r_O_G2.transpose())); I_O_m2_A
Out[17]:
In [18]:
I_O_A = simplify(I_O_cab + I_O_m1_A + I_O_m2_A); I_O_A
Out[18]:
In [ ]: